package cn.yunhe.controller;

import cn.yunhe.entity.User;
import cn.yunhe.pojo.UserQuestionRate;
import cn.yunhe.service.UserQuestionRateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class UserQuestionRateController {
    @Autowired
    @Qualifier("userQuestionRateService")
    private UserQuestionRateService userQuestionRateService;
    @RequestMapping("/getQuesHRate")
    public List<UserQuestionRate> getQuesHRate(HttpSession session, HttpServletRequest request){
       User user = (User) session.getAttribute("Curr_User");
       int fieldid = Integer.parseInt(request.getParameter("id"));
       session.setAttribute("fid",fieldid);
        System.out.println(fieldid);


       List<UserQuestionRate> userQuestionRates =  userQuestionRateService.getQuesHRate(fieldid,user.getUserId());
       return userQuestionRates;
    }


}
